package com.ytjj.qmyx.admin.controller;

import com.ytjj.common.api.CommonResult;
import com.ytjj.qmyx.admin.service.MenuApiService;
import com.ytjj.qmyx.mall.model.MenuApi;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 *
 * 
 * @Version: 1.0
 */
@RestController
@RequestMapping("/menuApi")
public class MenuApiController {

	@Resource
	private MenuApiService menuApiService;

	@GetMapping("/list")
	public CommonResult getMenuApiList() {
		return CommonResult.success(menuApiService.getMenuApiList());
	}

	@GetMapping("/chooseMenu")
	public CommonResult chooseMenu(@RequestParam String menuName) {
		return CommonResult.success(menuApiService.chooseMenu(menuName));
	}

	@PostMapping("/addMenuApi")
	public CommonResult addMenuApi(@RequestBody MenuApi menuApi) {
		menuApiService.addMenuApi(menuApi);
		return CommonResult.success();
	}

	@PostMapping("/updateMenuApi")
	public CommonResult updateMenuApi(@RequestBody MenuApi menuApi) {
		menuApiService.updateMenuApi(menuApi);
		return CommonResult.success();
	}

	@GetMapping("/deleteMenuApi")
	public CommonResult deleteMenuApi(@RequestParam Integer id) {
		menuApiService.deleteMenuApi(id);
		return CommonResult.success();
	}
}
